{% import 'macro/svg.html' as SVG %}
{% import 'macro/oops.html' as OOPS %}
<div class="container-xl">
  <div class="page-header d-print-none">
    <div class="row align-items-center">
      <div class="col">
        <h2 class="page-title">
          电视剧订阅
        </h2>
      </div>
      <div class="col-auto ms-auto d-print-none">
        <div class="btn-list">
          <a href="javascript:show_add_rss_media_modal('TV')" class="btn btn-primary d-none d-sm-inline-block">
            {{ SVG.plus() }}
            新增订阅
          </a>
          <a href="javascript:show_add_rss_media_modal('TV')" class="btn btn-primary d-sm-none btn-icon">
            {{ SVG.plus() }}
          </a>
          <a href="javascript:navmenu('rss_history?t=TV')" class="btn d-none d-sm-inline-block">
            {{ SVG.history() }}
            订阅历史
          </a>
          <a href="javascript:navmenu('rss_history?t=TV')" class="btn d-sm-none btn-icon" title="RSS解析器">
            {{ SVG.history() }}
          </a>
        </div>
      </div>
    </div>
  </div>
</div>
{% if Count > 0 %}
  <div class="page-body">
    <div class="container-xl">
      <div class="d-grid gap-3 grid-normal-card">
        {% for Id, Attr in Items.items() %}
          <a class="card card-link-pop rounded-3 p-0"
             href='javascript:{% if Attr.tmdbid %}show_mediainfo_modal("TV", "{{ Attr.name }}", "{{ Attr.year }}", "{{ Attr.tmdbid }}", "tv_rss", "{{ Attr.id }}"){% else %}show_edit_rss_media_modal("{{ Attr.id }}", "TV"){% endif %}'>
            <div class="text-center" style="overflow:hidden">
              <custom-img img-class="rounded-top w-100"
                          img-src="{{ Attr.image }}"
                          img-ratio="60%"
                          img-style="border-top-left-radius:var(--tblr-border-radius-lg) !important; border-top-right-radius:var(--tblr-border-radius-lg) !important; object-fit:cover;"
              ></custom-img>
            </div>
            <div class="card-progress" style="overflow: hidden">
              <div class="progress-bar bg-green"
                   style="width:{% if (Attr.total or -1) > 0 %}{{ ((Attr.total or -1)-(Attr.lack or -1))*100/(Attr.total or -1) }}{% endif %}%"
                   role="progressbar"
                   aria-valuenow="{% if (Attr.total or -1) > 0 %}{{ ((Attr.total or -1)-(Attr.lack or -1))*100/(Attr.total or -1) }}{% endif %}"
                   aria-valuemin="0" aria-valuemax="100">
              </div>
            </div>
            <div class="card-body text-center">
              <div class="card-title mb-1 text-truncate">
                {% if Attr.year %}
                  {{ Attr.name }} ({{ Attr.year }}) {% if Attr.season != "S00" %}{{ Attr.season }}{% endif %}
                {% else %}
                  {{ Attr.name }} {% if Attr.season != "S00" %}{{ Attr.season }}{% endif %}
                {% endif %}
              </div>
              <div class="text-muted">
                {% if Attr.state == 'D' %}
                  <span class="badge bg-gray"></span>  队列中
                {% elif Attr.state == 'S' %}
                  <span class="badge bg-orange"></span>  正在搜索
                {% elif Attr.state == 'R' %}
                  <span class="badge bg-green"></span>  正在订阅
                  {% if (Attr.total or -1) > 0 %}
                    ({{ (Attr.total or -1) - (Attr.lack or -1) }}/{{ (Attr.total or -1) }})
                  {% endif %}
                {% else %}
                  <span class="badge bg-blue"></span>  完成
                {% endif %}
              </div>
              <div{% if Attr.over_edition or
                    Attr.filter_restype or
                    Attr.filter_pix or
                    Attr.filter_team or
                    (Attr.download_setting and Attr.download_setting != -1) or
                    Attr.rss_sites or
                    Attr.search_sites %} class="text-muted border-top pt-2 mt-2"
              {% else %} class=“text-muted"{% endif %}>
                <small>
                  {% if Attr.over_edition %}
                    <span class="badge bg-red me-1 mb-1" title="已开启洗版">洗版</span>
                  {% endif %}
                  {% if Attr.download_setting|string in DownloadSettings %}
                    <span class="badge bg-red me-1 mb-1" title="下载设置">
                      {{ DownloadSettings[Attr.download_setting|string].name }}
                    </span>
                  {% endif %}
                  {% if Attr.filter_restype %}
                    <span class="badge bg-yellow me-1 mb-1" title="质量">
                      {{ Attr.filter_restype }}
                    </span>
                  {% endif %}
                  {% if Attr.filter_pix %}
                    <span class="badge bg-yellow me-1 mb-1" title="分辨率">
                      {{ Attr.filter_pix }}
                    </span>
                  {% endif %}
                  {% if Attr.filter_team %}
                    <span class="badge bg-yellow me-1 mb-1 text-wrap text-start" title="制作组/字幕组">
                      {{ Attr.filter_team }}
                    </span>
                  {% endif %}
                  {% if Attr.filter_rule|string in RuleGroups %}
                    <span class="badge bg-orange me-1 mb-1" title="过滤规则">
                      {{ RuleGroups[Attr.filter_rule|string] }}
                    </span>
                  {% endif %}
                </small>
              </div>
              <div class="text-muted">
                <small>
                  {% for Site in Attr.rss_sites %}
                    <span class="badge badge-outline text-azure me-1 mb-1" title="订阅站点">
                      {{ Site }}
                    </span>
                  {% endfor %}
                  {% for Site in Attr.search_sites %}
                    <span class="badge badge-outline text-teal me-1 mb-1" title="搜索站点">
                      {{ Site }}
                    </span>
                  {% endfor %}
                </small>
              </div>
            </div>
          </a>
        {% endfor %}
      </div>
    </div>
  </div>
{% else %}
{{ OOPS.nodatafound('没有订阅', '当前没有正在订阅的电视剧。') }}
{% endif %}
